"""
example:
1. { ## 用戶未登入
    "_event_id": "active", "user_id": null, "_event_time": 1540380121,
    "ip": "1.2.3.4", "chn": "ios_1", "aid": "test_aid_1"
    }
2. { ## 用戶登入
    "_event_id": "active", "user_id": 12345, "_event_time": 1540380121,
    "ip": "1.2.3.4", "chn": "ios_1", "aid": "test_aid_1"
    }
"""

EVENT_RULES = {
    "aggs": {
        "groups": [
            {
                "group_name": "渠道",
                "field_id": "_chn",
                "is_keyword": True,
                "field_name": "渠道"
            }
        ],
        "values": [],
        "uv": {
            "field_id": "_user_id",
            "field_name": "活跃人次"
        },
        "pv": {
            "field_name": "活跃次数"
        }
    }
}


EVENT_CONFIG = {
    "event_id": "active",
    "event_name": "用户活跃",
    "values": {
        "_user_id": {
            "field_name": "用戶ID",
            "value_type": "long",
            "allow_null": True,
        },
        "_ip": {
            "field_name": "IP",
            "value_type": "string",
        },
        "_chn": {
            "field_name": "渠道",
            "value_type": "string"
        },
        "_aid": {
            "field_name": "设备ID",
            "value_type": "string"
        },
        "_cvc": {
            "field_name": "设备版本号",
            "value_type": "string",
            "required": False,
        },
        "_device_type": {
            "field_name": "设备类型, 0 web, 1 Android, 2 iOS",
            "value_type": "long",
            "required": False,
        },
        "_ua": {
            "field_name": "设备型号",
            "value_type": "string",
            "required": False,
        }
    },
    "rule": EVENT_RULES
}
